<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('sys_email列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>邮件名称：</label>
                            <input type="text" name="emailName"/>
                        </li>
                        <li>
                            <label>发件人：</label>
                            <input type="text" name="outName"/>
                        </li>
                        <li>
                            <label>信件类型：</label>
                            <select name="type" id="type">
                                <option value=""></option>
                                <option value="0">普通邮件</option>
                                <option value="1">机密邮件</option>
                            </select>
                        </li>
                        <li>
                            <label>信件状态：</label>
                            <select name="state" id="state">
                                <option value=""></option>
                                <option value="1">未读</option>
                                <option value="0">已读</option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <!--   <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:email:add">
                   <i class="fa fa-plus"></i> 添加
               </a>
               <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:email:edit">
                   <i class="fa fa-edit"></i> 修改
               </a>-->
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:email:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <!--       <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:email:export">
                       <i class="fa fa-download"></i> 导出
                   </a>-->
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:email:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:email:remove')}]];
    var prefix = ctx + "system/email";

    $(function() {
        // 获取数据字典数据
        var datas = [[${@dict.getType('sys_email_type')}]];
        var data = [[${@dict.getType('email_read')}]];

        var options = {
            url: prefix + "/showlist",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/shouRemove",
            exportUrl: prefix + "/export",
            modalName: "sys_email",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '邮件编号',
                    // visible: false
                },
                {
                    field: 'emailName',
                    title: '邮件名称'
                },
                {
                    field: 'sysWzxUser.sysDept.deptName',
                    title: '所属部门'
                },
                {
                    field: 'type',
                    title: '邮件类型',
                    // 格式化数据字典
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'sysWzxUser.inName',
                    title: '收件人'
                },
                {
                    field: 'sysWzxUser.outName',
                    title: '发件人'
                },
                {
                    field: 'createTime',
                    title: '发件时间'
                },
                {
                    field: 'state',
                    title: '信件状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(data, value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>查看</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>